package com.zkthink.zhl.order.controller;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.zkthink.base.R;
import com.zkthink.base.controller.SuperController;
import com.zkthink.base.request.PageParams;
import com.zkthink.clh.order.dto.CouponsPageDTO;
import com.zkthink.clh.order.dto.CouponsSaveDTO;
import com.zkthink.clh.order.dto.CouponsUpdateDTO;
import com.zkthink.clh.order.entity.AppletVip;
import com.zkthink.clh.order.entity.ChlCoupons;
import com.zkthink.security.annotation.PreAuth;
import com.zkthink.zhl.order.service.ChlCouponsService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;


/**
 * <p>
 * 前端控制器
 * 车龙惠消费金表
 * </p>
 *
 * @author chenke
 * @date 2022-04-26
 */
@Slf4j
@Validated
@RestController
@RequestMapping("/coupons")
@Api(value = "Coupons", tags = "车龙惠消费金表")
public class ChlCouponsController extends SuperController<ChlCouponsService, Long, ChlCoupons, CouponsPageDTO, CouponsSaveDTO, CouponsUpdateDTO> {

    @ApiOperation(value = "添加惠消费金", notes = "添加惠消费金")
    @PostMapping("/addCoupons")
    public R addCoupons(@RequestBody CouponsSaveDTO dto)  {
        return baseService.addCoupons(dto);
    }

    @ApiOperation(value = "编辑惠消费金", notes = "编辑惠消费金")
    @PostMapping("/editCoupons")
    public R editCoupons(@RequestBody CouponsUpdateDTO dto) {
        return baseService.editCoupons(dto);
    }
    @ApiOperation(value = "假删除惠消费金", notes = "删除惠消费金")
    @GetMapping("/delectId/{id}")
    public R delectId(@PathVariable("id") Long id) {
        return baseService.delectId(id);
    }

    @ApiOperation(value = "后台查询惠消费金", notes = "后台查询惠消费金")
    @PostMapping(value = "/findCoupons")
    public R<IPage<ChlCoupons>> findCoupons(@RequestBody PageParams<CouponsPageDTO> dto) {
        CouponsPageDTO model = dto.getModel();
        IPage page = dto.getPage();
        return R.success(baseService.findCoupons(page, model));
    }

    @ApiOperation(value = "VIP列表", notes = "VIP列表")
    @GetMapping(value = "/selectVipList")
    public R findCoupons() {
        return R.success(baseService.selectVip());
    }

    @ApiOperation(value = "购买VIP", notes = "购买VIP")
    @GetMapping("/buyVip")
    public R buyVip(@PathVariable String vipId) {
        return baseService.buyVip(vipId);
    }

    @ApiOperation(value = "购买消费金", notes = "购买消费金")
    @GetMapping("/buyChlCoupons")
    public R buyChlCoupons(@PathVariable String chlCouponsId) {
        return baseService.buyChlCoupons(chlCouponsId);
    }
}
